<!--组合情景分析-->
<template>
  <div class="app-container">

    <el-form ref="qryProfitAnalyRel" :model="queryParams" :rules="rules" v-show="showSearch"
             label-width="68px">
      <el-row :gutter="1">
          <el-form-item label="组合" prop="groupId">
            <baseCombox url="/pricing/group/queryVGroupCombox.action"
                        clearable
                        multiple="true" collapse-tags collapse-tags-tooltip
                        valueField="dict_val"
                        labelField="dict_disp"
                        @change="selectUnderly"
                        size="small"
                        :style="{width:'200px'}" placeholder="组合" v-model="queryParams.groupId"></baseCombox>
          </el-form-item>
          <el-form-item class="itemSecene" label="价格情景:" label-width="78px">
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="priceCheck" label="是否偏移" label-width="68px">
            <el-checkbox size="small" v-model="queryParams.priceCheck"></el-checkbox>
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="priceOffsetType" label="偏移类型" label-width="68px">
            <DictCombox size="small" :disabled="!queryParams.priceCheck" v-model="queryParams.priceOffsetType"
                        dictType="priceOffsetType" placeholder="类型"></DictCombox>
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="priceLen" label="步长" label-width="48px">
            <el-input-number size="small" :disabled="!queryParams.priceCheck" v-model="queryParams.priceLen" :precision="stepPrecison1"
                             controls-position="right" placeholder="步长" :min="0" label="步长"></el-input-number>
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="priceHalf" label="步数" label-width="48px">
            <el-input-number size="small" :disabled="!queryParams.priceCheck" v-model="queryParams.priceHalf" precision="0"
                             :min="1" controls-position="right" placeholder="步数" label="步数"></el-input-number>
          </el-form-item>
          <el-form-item label="定价配置" prop="cfgId">
            <baseCombox url="/pricing/comboBox/queryPriceCfg4Local.action?productType=OtcOption" clearable
                        valueField="cfgId"
                        labelField="name"
                        size="small" @defaultSelect="(value) => {queryParams.cfgId = value}"
                        :defaultSelectIndex="'0'"
                         placeholder="定价配置" v-model="queryParams.cfgId"></baseCombox>
          </el-form-item>
      </el-row>
      <el-row :gutter="1">
          <el-form-item label="挂钩标的" prop="underlyerId">
            <underlyer clearable
                       ref="underlyerIdRef"
                       size="small"
                       :style="{width:'200px'}" placeholder="挂钩标的" :coverUnderlyerList="coverUnderlyerList"
                       v-model="queryParams.underlyerId"></underlyer>
          </el-form-item>
          <el-form-item class="itemSecene" label="波动率情景:" label-width="78px">
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="volCheck" label="是否偏移" label-width="68px">
            <el-checkbox size="small" v-model="queryParams.volCheck"></el-checkbox>
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="volType" label="偏移类型" label-width="68px">
            <DictCombox size="small" :disabled="!queryParams.volCheck" @change="volTypeChg"
                        v-model="queryParams.volType" dictType="percentOffsetType"></DictCombox>
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="volLen" label="步长" label-width="48px">
            <el-input-number size="small" :disabled="!queryParams.volCheck" v-model="queryParams.volLen" :precision="stepPrecison2"
                             controls-position="right" :min="0" label="步长"></el-input-number>
          </el-form-item>
          <el-form-item class="itemSeceneInner" prop="volHalf" label="步数" label-width="48px">
            <el-input-number size="small" :disabled="!queryParams.volCheck" v-model="queryParams.volHalf" :min="1" precision="0"
                             controls-position="right" label="步数"></el-input-number>
          </el-form-item>


          <el-form-item label="计算日期"  prop="dealDate" v-if="true">
            <el-date-picker value-format="YYYY-MM-DD" v-model="queryParams.dealDate"
                            type="date" size="small" :style="{width:'160px'}"
                            placeholder=""/>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" :loading="loading" size="small" @click="handleQuery"
                       style="margin: 3px 5px"
                       v-hasPermi="['risk:profitmanage:profitanalysis:calc']"
            >计算
            </el-button>
            <el-button :loading="loading" size="small" @click="handleExport"
                       style="margin: 3px 5px"
                       type="warning"
                       icon="Download"
                       v-hasPermi="['risk:profitmanage:profitanalysis:export']"
            >导出
            </el-button>
          </el-form-item>
            <el-button v-if="calTime!=null"
                       type="success"
                       style="margin: 3px 5px"
                       disabled="true"
                       size="small"
            >{{ calTime }}
            </el-button>
      </el-row>

    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            v-show="false"
            icon="Search"
            :disabled="single"
            size="small"
            @click="viewResult"
            v-hasPermi="['risk:profitmanage:profitanalysis:view']"
        >查看明细
        </el-button>
      </el-col>

    </el-row>
    <el-tabs tab-position="left" v-show="showFlag" v-model="activeName" type="card">
      <!--动态价值tab页-->
      <!--      <el-tab-pane-->
      <!--          v-for="item in greek"-->
      <!--          :key="item.value"-->
      <!--          :label="item.label"-->
      <!--          :name="item.value"-->
      <!--      >-->
      <!--        <component  :is="getTabInfo(item)" :getActiveName="getActiveName" :getResult="getResult"  />-->
      <!--      </el-tab-pane>-->
      <el-tab-pane name="npv" label="npv">
        <xTable ref="profitnpvRef" refId="profitnpvRef" multiple="false" v-loading="loading" :data="fundAnalysisList"
                border="true" :summary-method="summary" show-summary sum-text="风险均值"
        >
          <template #columList>
            <el-table-column label="序号" type="index" ></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />


            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsNpvList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="delta" label="delta">
        <xTable ref="profitdeltaRef" refId="profitdeltaRef" multiple="false" v-loading="loading"
                :data="fundAnalysisList" border="true" :summary-method="summary" show-summary sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index" ></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsDeltaList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="deltacash" label="deltacash">
        <xTable ref="profitdeltacashRef" refId="profitdeltacashRef" multiple="false" v-loading="loading"
                :data="fundAnalysisList" border="true" :summary-method="summary" show-summary sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsDeltaCashList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="gamma" label="gamma">
        <xTable ref="profitgammaRef" refId="profitgammaRef" multiple="false" v-loading="loading"
                :data="fundAnalysisList" stripe="true" border="true" :summary-method="summary" show-summary
                sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index" ></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsGammaList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="gammacash" label="gammacash">
        <xTable ref="profitgammacashRef" refId="profitgammacashRef" multiple="false" v-loading="loading"
                :data="fundAnalysisList" border="true" :summary-method="summary" show-summary sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index" ></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsGammaCashList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="theta" label="theta">
        <xTable ref="profitthetaRef" refId="profitthetaRef" multiple="false" v-loading="loading"
                :data="fundAnalysisList" border="true" :summary-method="summary" show-summary sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index" ></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true"/>
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsThetaList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="vega" label="vega">
        <xTable ref="profitvegaRef" refId="profitvegaRef" multiple="false" v-loading="loading" :data="fundAnalysisList"
                border="true" :summary-method="summary" show-summary sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index" ></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsVegaList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <el-tab-pane name="rho" label="rho">
        <xTable ref="profitrhoRef" refId="profitrhoRef" multiple="false" v-loading="loading" :data="fundAnalysisList"
                border="true" :summary-method="summary" show-summary sum-text="风险均值">
          <template #columList>
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="标的代码" align="center" prop="uICode" :show-overflow-tooltip="true" />
            <el-table-column label="标的名称" align="center" prop="uName" :show-overflow-tooltip="true" />
            <el-table-column :label="volOffsetTitle" align="right" :formatter="getVolPercent" prop="volSurfaceValInc"
                             :show-overflow-tooltip="true"    width="170"/>
            <el-table-column align="right" :formatter="formartEmptyTableP2" v-for="item in fundFieldsRhoList"
                             :prop="item.valueId"
                             :label="item.text"
                             :show-overflow-tooltip="true"
                             width="150"
            ></el-table-column>
          </template>
        </xTable>
      </el-tab-pane>
      <!-- 异常信息-->
      <el-tab-pane name="errInfo" :label="errTitle">
        <xTable ref="profitErrorRef" refId="profitErrorRef" multiple="false" v-loading="loading" :data="fundAnaErrList"
                border="true">
          <template #columList>
            <el-table-column label="序号" type="index" >
            </el-table-column>
            <el-table-column label="合约编号" align="left" prop="iCode" :show-overflow-tooltip="true" width="220"/>
            <el-table-column label="异常信息" align="left" prop="errInfo" :show-overflow-tooltip="true"/>
          </template>
        </xTable>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script setup name="Profitanalysis">

import {getFundCalResultList, getUnderlyListByProfit} from '@/api/risk/profitmanage/profitanalysis'
import baseCombox from '@/xquant/base/baseCombox'
import DictCombox from '@/xquant/base/dictCombox'
import Underlyer from '@/xquant/base/underlyer'
import xTable from '@/xquant/base/xTable'
import {formartNumber, formatAmountWithUseGrouping} from '../../../../utils/numberUtil'

const {proxy} = getCurrentInstance()
const showFlag = ref(true)
//希腊字母resultLits
const fundAnalysisList = ref([])
const stepPrecison1=ref(2);
const stepPrecison2=ref(3);
const fundAnaErrList = ref([])
//希腊字母field
const fundFieldsNpvList = ref([])
const fundFieldsDeltaList = ref([])
const fundFieldsDeltaCashList = ref([])
const fundFieldsGammaList = ref([])
const fundFieldsGammaCashList = ref([])
const fundFieldsThetaList = ref([])
const fundFieldsVegaList = ref([])
const fundFieldsRhoList = ref([])
const detailsList = ref([])
const title = ref('情景分析明细')
const open = ref(false)
const loading = ref(false)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
let begTime = ref(0)
let endTime = ref(0)
const errTitle = ref('异常信息')
const volOffsetTitle = ref('波动率偏移(绝对(%)\\价格')
//本次计算的实际标题 用于导出
const calcTitle=ref('波动率偏移(绝对(%)\\价格')
const activeName = ref('npv')
const {greek} = proxy.useDict('greek')
const calTime = ref(null)
const coverUnderlyerList = ref([])
const data = reactive({
  queryParams: {
    groupId: undefined,
    underlyerId: undefined,
    priceType: 'DP_CLOSE',
    dealDate: proxy.getSysDate(),
    // aTypes:['0','2'],
    cfgId: '',
    priceCheck: true,
    priceOffsetType: '0',
    priceLen: 2,
    priceHalf: 2,
    volCheck: true,
    volType: '1',
    volLen: 2,
    volHalf: 2

  },
  rules: {
    groupId: [{required: false, trigger: 'change'}],
    dealDate: [{required: true, message: '计算日期不能为空', trigger: 'change'}],
    underlyerId: [{required: true, message: '挂钩标的不能为空', trigger: 'change'}],
    aTypes: [{required: false, trigger: 'change'}],
    priceType: [{required: true, message: '价格类型不能为空', trigger: 'change'}],
    cfgId: [{required: true, message: '定价配置不能为空', trigger: 'change'}],
    priceOffsetType: [{required: true, message: '价格偏移类型不能为空', trigger: 'blur'}],
    priceLen: [{required: true, message: '价格偏移步长不能为空', trigger: 'blur'}],
    priceHalf: [{required: true, message: '价格偏移步数不能为空', trigger: 'blur'}],
    volType: [{required: true, message: '波动率偏移不能为空', trigger: 'blur'}],
    volLen: [{required: true, message: '波动率偏移步长不能为空', trigger: 'blur'}],
    volHalf: [{required: true, message: '波动率偏移步数不能为空', trigger: 'blur'}]
  }
})

const {queryParams, rules} = toRefs(data)

/** 查询列表 */
function getList() {
  loading.value = true
  //查询条件
  let param = {
    'groupId': proxy.lsh.join(queryParams.value.groupId, ','),
    'underlyerId': queryParams.value.underlyerId,
    'cfgId': queryParams.value.cfgId,
    'priceType': queryParams.value.priceType,
    'success': true,
    "dealDate":queryParams.value.dealDate
    // "aTypes":queryParams.value.aTypes.join(",")
  }
  if (queryParams.value.priceCheck) {
    let stepLength = queryParams.value.priceLen
    if (queryParams.value.priceOffsetType == '0') {
      stepLength = stepLength / 100
    }
    param = proxy.lsh.assign(param, {
      'priceScene': JSON.stringify({
        'type': queryParams.value.priceOffsetType,
        'stepLength': stepLength,
        'stepSize': queryParams.value.priceHalf
      })
    })
  }
  if (queryParams.value.volCheck) {
    let stepLength = queryParams.value.volLen / 100
    param = proxy.lsh.assign(param, {
      'volScene': JSON.stringify({
        'type': queryParams.value.volType,
        'stepLength': stepLength,
        'stepSize': queryParams.value.volHalf
      })
    })
  }
  //处理情景因子
  param = param = proxy.lsh.assign(param, {'calcSceneParams': getSceneParam(param)})
  getFundCalResultList(param).then(response => {
    activeName.value='';
    fundAnaErrList.value = response.msg.error
    getFieldsList(response.msg.fields)
    errTitle.value = '异常信息(' + response.msg.error.length + ')'
    loading.value = false
    endTime = new Date()
    calTime.value = '刷新时间: ' + proxy.getCurrTime('YYYY-mm-dd HH:MM:SS', new Date())
    fundAnalysisList.value = response.msg.success
    proxy.$modal.alertSuccess('计算完成!耗时：' + parseInt(endTime - begTime) / 1000 + '秒')
  }).finally(()=>{
    setTimeout(function () {
      activeName.value='npv';
    }, 100);
  })
}

/** 搜索按钮操作 */
function handleQuery() {
  proxy.$refs['qryProfitAnalyRel'].validate(valid => {
    if (valid) {
      begTime = new Date()
      calTime.value = '开始计算！' + proxy.getCurrTime('YYYY-mm-dd HH:MM:SS', new Date())
      getList()
    } else {
      reset()
    }
  })
}

/** 处理情景因子*/
function getSceneParam(param) {
  let sceneParam = []
  // 价格因子
  let chkScenePrice = queryParams.value.priceCheck
  let priceLen = 0
  let priceHalf = 0
  let priceType = 1
  if (chkScenePrice) {
    priceType = queryParams.value.priceOffsetType
    priceLen = queryParams.value.priceLen
    if (priceType == '0') {
      priceLen = priceLen / 100
    }
    priceHalf = Number.parseInt(queryParams.value.priceHalf) / 2
  }
  // 波动率因子
  var chkSceneVol = queryParams.value.volCheck
  var volLen = 0
  var volHalf = 0
  var volType = 1
  if (chkSceneVol) {
    volType = queryParams.value.volType
    volLen = queryParams.value.volLen / 100
    volHalf = queryParams.value.volHalf / 2
  }
  var sceneIndex = 0
  for (var i = -priceHalf; i <= priceHalf; i++) {
    var spotPriceInc = null
    if (priceHalf != 0) {
      spotPriceInc = {
        type: priceType,
        value: i * priceLen
      }
    }
    for (var j = -volHalf; j <= volHalf; j++) {
      var volSurfaceInc = null
      if (volHalf != 0) {
        volSurfaceInc = {
          type: volType,
          value: j * volLen
        }
      }
      sceneIndex++
      var sceneItem = {
        sceneID: 'scene' + sceneIndex,
        underlyingSceneParams: [{}]
      }
      if (spotPriceInc != null) {
        sceneItem.underlyingSceneParams[0].spotPriceInc = spotPriceInc
      }
      if (volSurfaceInc != null) {
        sceneItem.underlyingSceneParams[0].volSurfaceInc = volSurfaceInc
      }
      sceneParam.push(sceneItem)
    }
  }
  return JSON.stringify(sceneParam)
}

function summary(param) {
  return proxy.columnsCal(param, '风险均值', 2, 3, null, 2, '2')
  // return proxy.getSummary(param,'风险均值',2,3,null,2);
}

function volTypeChg(newVal) {
  let iTitle = queryParams.value.volType == 1 ? '绝对%' : '相对%'
  volOffsetTitle.value = '波动率偏移(' + iTitle + ')\\价格'
}

function getFieldsList(result) {
  let tmpNpvList = []
  let tmpDeltaList = []
  let tmpDeltaCashList = []
  let tmpGammaList = []
  let tmpGammaCashList = []
  let tmpThetaList = []
  let tmpVegaList = []
  let tmpRhoList = []
  for (let i = 0; i < result.length; i++) {
    if (result[i].indexOf('#') > -1 && result[i].split('#').length > 3) {
      if (result[i].split('#')[3] == 'npv') {
        tmpNpvList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'delta') {
        tmpDeltaList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'deltaCash') {
        tmpDeltaCashList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'gamma') {
        tmpGammaList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'gammaCash') {
        tmpGammaCashList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'theta') {
        tmpThetaList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'vega') {
        tmpVegaList.push(getData(result[i]))
      } else if (result[i].split('#')[3] == 'rho') {
        tmpRhoList.push(getData(result[i]))
      }
    }
  }
  fundFieldsNpvList.value = tmpNpvList
  fundFieldsDeltaList.value = tmpDeltaList
  fundFieldsDeltaCashList.value = tmpDeltaCashList
  fundFieldsGammaList.value = tmpGammaList
  fundFieldsGammaCashList.value = tmpGammaCashList
  fundFieldsThetaList.value = tmpThetaList
  fundFieldsVegaList.value = tmpVegaList
  fundFieldsRhoList.value = tmpRhoList
}

function reset() {
  errTitle.value = '异常信息'
  calTime.value = '当前时间: ' + proxy.getCurrTime('YYYY-mm-dd HH:MM:SS', new Date())
  //fields
  fundFieldsNpvList.value = []
  fundFieldsDeltaList.value = []
  fundFieldsDeltaCashList.value = []
  fundFieldsGammaList.value = []
  fundFieldsGammaCashList.value = []
  fundFieldsThetaList.value = []
  fundFieldsVegaList.value = []
  fundFieldsRhoList.value = []
  //result
  fundAnalysisList.value = []
  //error
  fundAnaErrList.value = []
}

function getData(result) {
  return {
    'tabId': result.split('#')[3],
    'text': formatAmountWithUseGrouping(Number(result.split('#')[1].replace('_', '.')), 2),
    'valueId': result
  }
}

function getVolPercent(row, column, cellValue) {
  return proxy.lsh.round(proxy.lsh.add(Number(cellValue), 1) * 100, 3) + '%'
}

//根据组合加载标的
function selectUnderly(val) {
  if (proxy.isNotVoid(val)) {
    getUnderlyListByProfit({'groupIds': val.join(',')}).then(response => {
      coverUnderlyerList.value = response.msg
      proxy.$refs['underlyerIdRef'].queryUnderlyersByCoverList({}, response.msg)
      queryParams.value.underlyerId = undefined
    })
  } else {
    coverUnderlyerList.value = []
    proxy.$refs['underlyerIdRef'].queryUnderlyersByCoverList({}, [])
    queryParams.value.underlyerId = undefined
  }

}


function handleExport() {
  if(fundAnalysisList.value==null||fundAnalysisList.value==undefined||fundAnalysisList.value.length==0){
    proxy.$modal.alertError('没有结果需要导出！');
    return;
  }
  let fieldObj={};
  fieldObj.npv=fundFieldsNpvList.value;
  fieldObj.delta=fundFieldsDeltaList.value,
      fieldObj.deltacash=fundFieldsDeltaCashList.value,
      fieldObj.gamma=fundFieldsGammaList.value,
      fieldObj.gammacash=fundFieldsGammaCashList.value,
      fieldObj.theta=fundFieldsThetaList.value,
      fieldObj.vega=fundFieldsVegaList.value,
      fieldObj.rho=fundFieldsRhoList.value
  proxy.download("/pricing/scene/export", {
    //列表值
    'calcResult':JSON.stringify(fundAnalysisList.value),
    //错误列表
    'errResult':JSON.stringify(fundAnaErrList.value),
    //当次计算的title
    'calcTitle':calcTitle.value,
    //希腊字母field 表头
    'field':JSON.stringify(fieldObj)
  }, `情景分析${new Date().getTime()}.xlsx`);
}
</script>
<style scoped>
.itemSecene .el-form-item__label {
  color: #686868;
  font-weight: 550;
}

.itemSeceneInner .el-form-item__label {
  color: #686868;
  font-weight: 550;
}
</style>
